package reflection;

import lombok.Data;

/**
 * 反射的常用方法
 */
public class Test03 {
    public static void main(String[] args) throws ClassNotFoundException {
        //方式一：
        Person s1 = new Student();
        Class c1 = s1.getClass();
        Class c0 = c1.getSuperclass();
        System.out.println(c0);

        //方式二：
        Class c2 = Class.forName("reflection.Student");

        //方式三：
        Class c3 = Student.class;

        System.out.println(c1);
        System.out.println(c2);
        System.out.println(c3);

        //方式四：
        Class c4 = Integer.TYPE;
        System.out.println(c4);

    }
}

@Data
class Person{
    public String name;
}

class Student extends Person{
    public Student(){
        this.name = "学生";
    }
}
class Teacher extends Person{
    public Teacher(){
        this.name = "老师";
    }
}
